package com.ygo.feihua.adapter;

import com.ygo.feihua.R;
import android.widget.*;
import android.view.*;
import com.ygo.feihua.BmobTable.*;
import android.content.*;
import java.util.*;
import com.ygo.feihua.*;

public class TieTypeAdapter extends BaseAdapter
{

	private List<TieType> data;
	private Context context;
	private ViewHolder vh;
	private Gongju gj;
	
	public TieTypeAdapter(Context context,List<TieType> data){
		this.context=context;
		this.data=data;
		gj=Gongju.getdx(context);
	}
	
	private class ViewHolder{
		ImageView itt_icon;
		TextView itt_name;
	}
	
	@Override
	public int getCount()
	{
		// TODO: Implement this method
		return data.size();
	}

	@Override
	public Object getItem(int p1)
	{
		// TODO: Implement this method
		return data.get(p1);
	}

	@Override
	public long getItemId(int p1)
	{
		// TODO: Implement this method
		return p1;
	}

	@Override
	public View getView(int position, View p2, ViewGroup p3)
	{
		if(p2==null){
			vh=new ViewHolder();
			p2=LayoutInflater.from(context).inflate(R.layout.item_tie_type,null);
			vh.itt_icon=(ImageView) p2.findViewById(R.id.itt_icon);
			vh.itt_name=(TextView) p2.findViewById(R.id.itt_name);
			
			p2.setTag(vh);
		}else{
			vh=(TieTypeAdapter.ViewHolder) p2.getTag();
		}
		
		TieType tp=data.get(position);
		vh.itt_name.setText(tp.getName());
		gj.tuxian(tp.getIcon(),vh.itt_icon);
		
		
		// TODO: Implement this method
		return p2;
	}
	
	
	
}
